import { request } from '@umijs/max';
import { PageResponse } from '.';
import { FileDetail } from './index';
// 更新里程碑接口定义
export interface Milestone {
  id?: number;
  eventDate: string;
  description: string;
  imageObjs: FileDetail[];
  videoObjs: FileDetail[];
  famousPersonId: number;
}

// 分页查询请求名人里程碑
export interface MilestonePageRequest {
  pageCurrent: number;
  pageSize: number;
  famousPersonId: number;
  description?: string;
  startDate?: string;
  endDate?: string;
  order?: 'asc' | 'desc';
}


// 获取名人里程碑
export const getMilestoneList = async (id: number) => {
  return await request<Milestone[]>(`/growth-timelines/${id}`);
};

// 添加名人里程碑
export const addMilestone = async (milestone: Milestone) => {
  return await request('/growth-timelines/back', {
    method: 'POST',
    data: milestone,
  });
};

// 更新名人里程碑
export const updateMilestone = async (milestone: Milestone) => {
  return await request(`/growth-timelines/back`, {
    method: 'PUT',
    data: milestone,
  });
};

// 删除名人里程碑
export const deleteMilestone = async (idList: number[]) => {
  const ids = idList.join(',');
  return await request(`/growth-timelines/back/${ids}`, {
    method: 'DELETE',
  });
};

// 分页查询里程碑
export const getMilestonePage = async (params: MilestonePageRequest) => {
  return await request<PageResponse<Milestone>>('/growth-timelines/back/pageList', {
    method: 'POST',
    data: params,
  });
};

